package com.example.springfeature.controller;

import com.example.springfeature.bean.BaseParam;
import com.example.springfeature.bean.SysAppParam;
import com.example.springfeature.bean.TestDicReq;
import com.example.springfeature.bean.TestReq;
import com.example.springfeature.restful.ResultVO;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "test模块")
@RestController
@RequestMapping("/api")
public class TestApi {

    /**
     * 枚举值校验----rest开发中后端校验 参数是否为合法的系统定义的JAVA枚举值
     * @param req
     * @return
     */
    @ApiOperation(value = "枚举值校验-自定义jsr303注解")
    @ApiOperationSupport(order = 1,includeParameters = {"prefix","type","keyLock"})
    @GetMapping("/testFlag")
    public ResultVO<TestReq> testFlag(@Validated(TestReq.select.class) TestReq req) {
        return ResultVO.ok(req);
    }


    /**
     * 字典值校验----rest开发中后端校验 参数是否为合法的系统定义的Mysql字典值
     * @param req
     * @return
     */
    @ApiOperation(value = "字典值校验-自定义jsr303注解")
    @ApiOperationSupport(order = 3,includeParameters = {"dicVal"})
    //api文档里排序为2，只显示参数 dicVal的相关描述
    @GetMapping("/testDic")
    public ResultVO<TestDicReq>  testDic(@Validated(TestDicReq.select.class) TestDicReq  req){
        //@Validated 只校验 TestDicReq.class里被select分组标注过的参数
        return ResultVO.ok(req);
    }



    @ApiOperation(value = "时间字符串校验-自定义jsr303注解")
    @ApiOperationSupport(order = 2,includeParameters = {"timeStr"})
    @GetMapping("/testTime")
    public ResultVO<TestReq>  testTime(@Validated(TestReq.time.class) TestReq req){
        //@Validated 只校验 TestDicReq.class里被 time 分组标注过的参数
        return ResultVO.ok(req);
    }





}
